﻿using System.Collections.Generic;
using LBoL.Base;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Battle;
using LBoLEntitySideloader.Attributes;
using ProbeMod.Cards.Template;
using ProbeMod.StatusEffects;

namespace ProbeMod.Cards
{
    public sealed class ProbeExpandDef : ProbeCardTemplate
    {
        public override CardConfig MakeConfig()
        {
            CardConfig config = GetCardDefaultConfig();

            config.Rarity = Rarity.Uncommon;
            config.Type = CardType.Ability;
            config.TargetType = TargetType.Nobody;

            config.Colors = new List<ManaColor>() { ManaColor.White };
            config.Cost = new ManaGroup() { White = 2 };
            config.UpgradedCost = new ManaGroup() { White = 1 };
            config.IsXCost = true;

            config.Index = CardIndexGenerator.GetUniqueIndex(config);
            return config;
        }
    }

    /// <summary>
    /// 扩张
    /// 回合开始获得1点随机法力/2
    /// 每额外支付2：回合开始额外获得1点
    /// </summary>
    [EntityLogic(typeof(ProbeExpandDef))]
    public sealed class ProbeExpand : ProbeCard
    {
        public int initMana => IsUpgraded ? 2 : 1;

        protected override IEnumerable<BattleAction> Actions(UnitSelector selector, ManaGroup consumingMana, Interaction precondition)
        {
            var mana = (SynergyAmount(consumingMana,ManaColor.Any) - SynergyAmount(Cost,ManaColor.Any)) /2;
            yield return BuffAction<ProbeExpandSe>(level: initMana);
            yield return BuffAction<ProbeExpandSe>(level: mana);
        }
    }
}
